﻿<UserControl x:Class="DocumentManagement.Views.ShowItemCreateDocumentUserControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:vm="clr-namespace:DocumentManagement.ViewsModels"
             mc:Ignorable="d" 
             d:DesignHeight="768" d:DesignWidth="1024" xmlns:my="clr-namespace:DocumentManagement.Converters" Background="#60F89BFF">
    
    <UserControl.Resources>
        <vm:ShowItemCreatedocumentViewsModel x:Key="showItemCreatedocumentViewsModel"/>
      
        <ContextMenu x:Key="MyContextMenu">
            <MenuItem Header="สร้างหนังสือออก" Name="addCreateOUTDocMenu" Click="addCreateOUTDocMenu_Click" />
            <MenuItem Header="Copy หนังสือออก" Name="copyCreateOUTDocMenu" Click="copyCreateOUTDocMenu_Click" />
            <MenuItem Header="แก้ไขหนังสือออก" Name="editCreateOUTDocMenu" Click="editCreateOUTDocMenu_Click" />
            <MenuItem Header="ลบหนังสือออก" Name="deleteCreateOUTDocMenu" Click="deleteCreateOUTDocMenu_Click" />
        </ContextMenu>
        <my:TextSpeedConverter x:Key="textSpeedConverter" />
        <my:DateConverter x:Key="dateConverter" />
        <my:TextStatusConverter x:Key="textStatusConverter" />
    </UserControl.Resources>


            <Grid Margin="10,10,12,29" DataContext="{Binding Source={StaticResource showItemCreatedocumentViewsModel}}" >
                <Grid.RowDefinitions>
                    <RowDefinition Height="35" />
                    <RowDefinition Height="30" />
                    <RowDefinition Height="*" />
                </Grid.RowDefinitions>
                <StackPanel Height="35" Name="stackPanel2" Orientation="Horizontal" VerticalAlignment="Center">
                    <TextBlock FontSize="16" Height="23" Margin="0,5,0,0" Name="textBlock2" Text="ค้นหารายการสร้างหนังสือออก" TextAlignment="Center" VerticalAlignment="Center" Width="254" FontFamily="Tahoma" FontWeight="Bold" />
                </StackPanel>
                <StackPanel Grid.Row="1" Height="30" Name="stackPanel3" Orientation="Horizontal">
                    <TextBlock FontSize="14" Height="23" Name="textBlock4" Text="เลขที่หนังสือ/ชื่อเรื่อง :" TextAlignment="Right" Width="150" FontFamily="Tahoma" FontWeight="Normal" />
                    <TextBox FontSize="14" Height="23"  Margin="10,0,0,0" Name="CreateSendCodeOrTitleTextBox" Width="298" KeyUp="CreateSendCodeOrTitleTextBox_KeyUp" FontFamily="Tahoma" FontWeight="Normal" />
                    <TextBlock FontSize="14" Height="21" Name="textBlock6" Text="จากวันที่ :" TextAlignment="Right" Width="80" FontFamily="Tahoma" FontWeight="Normal" />
                    <DatePicker FontSize="14" Height="28" Margin="10,0,0,0" Name="FromDatePicker"  Width="115" SelectedDateChanged="FromDatePicker_SelectedDateChanged" FontFamily="Tahoma" FontWeight="Normal" />
                    <TextBlock FontSize="14" Height="21" Name="textBlock7" Text="ถึงวันที่ :" TextAlignment="Right" Width="80" FontFamily="Tahoma" FontWeight="Normal" />
                    <DatePicker FontSize="14" Height="28" Margin="10,0,0,0" Name="ToDatePicker"  Width="115" SelectedDateChanged="ToDatePicker_SelectedDateChanged" FontFamily="Tahoma" FontWeight="Normal" />
                </StackPanel>
        <DataGrid AlternatingRowBackground="#60F89BFF" AutoGenerateColumns="False" CanUserReorderColumns="True" CanUserResizeColumns="True" CanUserResizeRows="True" CanUserSortColumns="True" ContextMenu="{StaticResource MyContextMenu}" FontSize="14" Grid.Row="2" IsManipulationEnabled="False" IsReadOnly="True" ItemsSource="{Binding Path=MyCreateDocumentICV, Mode=TwoWay}" Margin="0,5,0,0" Name="ShowCreateDataGrid" SelectedItem="{Binding Path=MySelectedEditItemCreateSend, Mode=TwoWay}" FontFamily="Tahoma" FontWeight="Normal">
                    <DataGrid.Columns>
                <DataGridTextColumn Binding="{Binding Path=CreateSendID, Mode=TwoWay}" Header="รหัส" />
                <DataGridTextColumn Binding="{Binding Path=CreateSendCode, Mode=TwoWay}" Header="เลขที่หนังสือออก" />
                <DataGridTextColumn Binding="{Binding Path=CreateSendDate, Mode=TwoWay, Converter={StaticResource dateConverter}, StringFormat=\{0:d\}}" Header="วันที่ออกหนังสือ" />
                <DataGridTextColumn Binding="{Binding Path=Division_FromDivision.ThaiName, Mode=TwoWay}" Header="จากหน่วยงาน" />
                <DataGridTextColumn Binding="{Binding Path=Division_ToDivision.ThaiName, Mode=TwoWay}" Header="ถึงหน่วยงาน" />
                <DataGridHyperlinkColumn Binding="{Binding Path=Title, Mode=TwoWay}" Header="ชื่อเรื่อง/สิ่งที่ส่งมาด้วย">
                    <DataGridHyperlinkColumn.ElementStyle>
                        <Style>
                            <EventSetter Event="Hyperlink.Click" Handler="DG_HyperlinkCreateSend_Click" />
                        </Style>
                    </DataGridHyperlinkColumn.ElementStyle>
                </DataGridHyperlinkColumn>
                <DataGridTextColumn Binding="{Binding Path=ToPosition, Mode=TwoWay}" Header="เรียน" />
                <DataGridTextColumn Binding="{Binding Path=Speed, Mode=TwoWay, Converter={StaticResource textSpeedConverter}}" Header="ชั้นความเร็ว">
                    <DataGridTextColumn.ElementStyle>
                        <Style TargetType="{x:Type TextBlock}">
                            <Style.Triggers>
                                <Trigger Property="Text" Value="ปกติ">
                                    <Setter Property="Foreground" Value="Black"/>
                                </Trigger>
                                <Trigger Property="Text" Value="ด่วน" >
                                    <Setter Property="Foreground" Value="Red"/>
                                </Trigger>
                                <Trigger Property="Text" Value="ด่วนมาก">
                                    <Setter Property="Foreground" Value="Red"/>
                                </Trigger>
                                <Trigger Property="Text" Value="ด่วนที่สุด">
                                    <Setter Property="Foreground" Value="Red"/>
                                </Trigger>
                            </Style.Triggers>

                        </Style>
                    </DataGridTextColumn.ElementStyle>
                </DataGridTextColumn>
                <!--<DataGridTextColumn Binding="{Binding Path=NameInstitution, Mode=TwoWay}" Header="ชื่อหน่วยงานราชการ" />
                <DataGridTextColumn Binding="{Binding Path=Address, Mode=TwoWay}" Header="ที่อยู่" />-->
                <DataGridTextColumn Binding="{Binding Path=Type, Mode=TwoWay, Converter={StaticResource textStatusConverter}}" Header="ชนิดหนังสือ" />

               

                <!--<DataGridTextColumn Binding="{Binding Path=Reference, Mode=TwoWay}" Header="อ้างถึง" />-->
                <!--<DataGridHyperlinkColumn Binding="{Binding Path=Title, Mode=TwoWay}" Header="สิ่งที่ส่งมาด้วย">-->
                    <!--<DataGridHyperlinkColumn.ElementStyle>
                        <Style>
                            <EventSetter Event="Hyperlink.Click" Handler="DG_Hyperlink2_Click" />
                        </Style>
                    </DataGridHyperlinkColumn.ElementStyle>-->
                <!--</DataGridHyperlinkColumn>-->
                <!--<DataGridTextColumn Binding="{Binding Path=Paragraph1, Mode=TwoWay}" Header="ย่อหน้าที่ 1" />
                <DataGridTextColumn Binding="{Binding Path=Paragraph2, Mode=TwoWay}" Header="ย่อหน้าที่ 2" />
                <DataGridTextColumn Binding="{Binding Path=Paragraph3, Mode=TwoWay}" Header="ย่อหน้าที่ 3" />
                <DataGridTextColumn Binding="{Binding Path=PostScript, Mode=TwoWay}" Header="คำลงท้าย" />
                <DataGridTextColumn Binding="{Binding Path=Endorser, Mode=TwoWay}" Header="ผู้ลงนาม" />
                <DataGridTextColumn Binding="{Binding Path=Position, Mode=TwoWay}" Header="ตำแหน่งงาน" />
                <DataGridTextColumn Binding="{Binding Path=BelongTo, Mode=TwoWay}" Header="สังกัด" />
                <DataGridTextColumn Binding="{Binding Path=Division.ThaiName, Mode=TwoWay}" Header="ส่วนงานเจ้าของเรื่อง" />
                <DataGridTextColumn Binding="{Binding Path=Tell, Mode=TwoWay}" Header="โทรศัพท์" />
                <DataGridTextColumn Binding="{Binding Path=Fax, Mode=TwoWay}" Header="โทรสาร" />-->
               
                <!--<DataGridTextColumn Binding="{Binding Path=Active, Mode=TwoWay}" Header="active" />-->
                <DataGridTextColumn Binding="{Binding Path=LogID, Mode=TwoWay}" Header="ผู้บันทึกรายการ" />

            </DataGrid.Columns>
                </DataGrid>
            </Grid>
      

</UserControl>
